home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / gplot3_2.lha / gnuplot / corplot.c < prev    next >
C/C++ Source or Header  |  1992-03-25  |  2KB  |  81 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: corplot.c,v 3.26 92/03/24 22:36:10 woo Exp Locker: woo $";
  3. #endif
  4.  
  5. /* GNUPLOT - corplot.c */
  6. /*
  7.  * Copyright (C) 1986, 1987, 1990, 1991, 1992   Thomas Williams, Colin Kelley
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted, 
  11.  * provided that the above copyright notice appear in all copies and 
  12.  * that both that copyright notice and this permission notice appear 
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed 
  17.  * as patches to released version.
  18.  *  
  19.  * This software is provided "as is" without express or implied warranty.
  20.  * 
  21.  *
  22.  * AUTHORS
  23.  * 
  24.  *   Original Software:
  25.  *     Thomas Williams,  Colin Kelley.
  26.  * 
  27.  *   Gnuplot 2.0 additions:
  28.  *       Russell Lang, Dave Kotz, John Campbell.
  29.  *
  30.  *   Gnuplot 3.0 additions:
  31.  *       Gershon Elber and many others.
  32.  * 
  33.  * Send your comments or suggestions to 
  34.  *  info-gnuplot@ames.arc.nasa.gov.
  35.  * This is a mailing list; to join it send a note to 
  36.  *  info-gnuplot-request@ames.arc.nasa.gov.  
  37.  * Send bug reports to
  38.  *  bug-gnuplot@ames.arc.nasa.gov.
  39.  */
  40. #include <stdio.h>
  41. #include <process.h>
  42. #include <dos.h>
  43.  
  44. #define BOUNDARY 32768
  45. #define segment(addr) (FP_SEG(m) + ((FP_OFF(m)+15) >> 4));
  46. #define round(value,boundary) (((value) + (boundary) - 1) & ~((boundary) - 1))
  47.  
  48. char *malloc(),*realloc();
  49.  
  50. char prog[] = "gnuplot";
  51. char corscreen[] = "CORSCREEN=0";
  52.  
  53. main()
  54. {
  55. register unsigned int segm,start;
  56. char *m;
  57.     if (!(m = malloc(BOUNDARY))) {
  58.         printf("malloc() failed\n");
  59.         exit(1);
  60.     }
  61.     segm = segment(m);
  62.     start = round(segm,BOUNDARY/16);
  63.  
  64.     if (realloc(m,BOUNDARY+(start-segm)*16) != m) {
  65.         printf("can't realloc() memory\n");
  66.         exit(2);
  67.     }
  68.  
  69.     if ((segm = start >> 11) >= 8) {
  70.         printf("not enough room in first 256K\n");
  71.         exit(3);
  72.     }
  73.  
  74.     corscreen[sizeof(corscreen)-2] = '0' + segm;
  75.     if (putenv(corscreen))
  76.         perror("putenv");
  77.  
  78.     if (spawnlp(P_WAIT,prog,prog,NULL))
  79.         perror("spawnlp");
  80. }
  81.